//
//  ChatImageCell.swift
//  
//
//  Created by Author on 2023/3/16.
//  Copyright © 2023 Author. All rights reserved.
//

import UIKit

class ChatImageCell: BaseTableViewCell {
    var longPressClosure:((_ imgModel: ImageMsgModel)->Void)?
    private(set) lazy var imgView :UIImageView = {
        let imgView = UIImageView()
        imgView.layer.cornerRadius = 12
        imgView.layer.masksToBounds = true
        imgView.isUserInteractionEnabled = true
        imgView.contentMode = .scaleAspectFill
        return imgView
    }()
   
    override func setupUI() {
        super.setupUI()
        wrapView.addSubview(imgView)
        let logTap = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction))
        wrapView.addGestureRecognizer(logTap)

        imgView.snp.makeConstraints { make in
            make.top.bottom.leading.trailing.equalToSuperview()
            make.size.equalTo(0)
        }
        
    }
    
    override func updateData() {
        
        super.updateData()
        imgView.image = UIImage(named: "demo")
    
        wrapView.snp.updateConstraints { make in
            
            make.trailing.equalTo(-21)
        }
      
        imgView.snp.updateConstraints { make in
            make.size.equalTo(CGSize(width: 130, height: 130))
        }
        sendBubbleImgView.isHidden = true
    }

    @objc private func longPressAction(){
        guard let imgModel = msg as? ImageMsgModel  else {return}
        self.eventCallback?(.CellImageLongPress,imgModel)
    }
    
    
    
}

